package com.bee.base.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class GenericUtil {

	public static Class<?> getGenericClass(Class<?> clazz) {
		Type genType = clazz.getGenericSuperclass();
		if (genType instanceof ParameterizedType) {
			Type[] params = ((ParameterizedType) genType).getActualTypeArguments();

			if ((params != null) && (params.length == 1)) {
				return (Class<?>) params[0];
			}
		}
		return null;
	}

}
